package pit.com.ordermobilesystem.sharepreference;

import pit.com.ordermobilesystem.constant.OrderConstant;
import android.content.Context;
import android.content.SharedPreferences;
import android.provider.SyncStateContract.Constants;

public class OrderSharePreference {
	final static String DATA="data";
	final static String DOWN_LOAD_SYNC="DOWN_LOAD_SYNC";
	final static String UP_LOAD_SYNC="UP_LOAD_SYNC";
	final static String SALE_ID="SALE_ID";
	final static String ADMIN="ADMIN";
	final static String USER="USER";
	final static String HOST="HOST";
	final static String PORT="PORT";
	final static String SHOP="SHOP";
	public static boolean getDownloadSync(Context mContext){
		SharedPreferences ref = mContext.getSharedPreferences(DATA, 0);
		boolean sync = ref.getBoolean(DOWN_LOAD_SYNC, true);
		return sync;		
	}

	
	public static void setDownloadSync(Context mContext, boolean sync) {
		SharedPreferences ref = mContext.getSharedPreferences(
				DATA, 0);
		SharedPreferences.Editor editor = ref.edit();
		editor.putBoolean(DOWN_LOAD_SYNC, sync);
		editor.commit();

	}
	
	
	public static boolean getUpSync(Context mContext){
		SharedPreferences ref = mContext.getSharedPreferences(DATA, 0);
		boolean sync = ref.getBoolean(UP_LOAD_SYNC, true);
		return sync;		
	}
	
	public static void setUploadSync(Context mContext, boolean sync) {
		SharedPreferences ref = mContext.getSharedPreferences(
				DATA, 0);
		SharedPreferences.Editor editor = ref.edit();
		editor.putBoolean(UP_LOAD_SYNC, sync);
		editor.commit();
	}
	
	public static String getHost(Context mContext){
		SharedPreferences ref = mContext.getSharedPreferences(DATA, 0);
		String host = ref.getString(HOST, OrderConstant.SERVER_HOST);
		return OrderConstant.SERVER_HOST;		
	}

	
	public static void setHost(Context mContext, String host) {
		SharedPreferences ref = mContext.getSharedPreferences(
				DATA, 0);
		SharedPreferences.Editor editor = ref.edit();
		editor.putString(HOST, host);
		editor.commit();

	}	
	
	public static String getPort(Context mContext){
		SharedPreferences ref = mContext.getSharedPreferences(DATA, 0);
		String host = ref.getString(PORT, OrderConstant.SERVER_PORT);
		return host;		
	}

	
	public static void setPort(Context mContext, String port) {
		SharedPreferences ref = mContext.getSharedPreferences(
				DATA, 0);
		SharedPreferences.Editor editor = ref.edit();
		editor.putString(PORT, port);
		editor.commit();

	}
	
	public static String getUser(Context mContext){
		SharedPreferences ref = mContext.getSharedPreferences(DATA, 0);
		String host = ref.getString(USER, "");
		return host;		
	}

	
	public static void setUser(Context mContext, String user) {
		SharedPreferences ref = mContext.getSharedPreferences(
				DATA, 0);
		SharedPreferences.Editor editor = ref.edit();
		editor.putString(USER, user);
		editor.commit();

	}	

	public static String getShop(Context mContext){
		SharedPreferences ref = mContext.getSharedPreferences(DATA, 0);
		String host = ref.getString(SHOP, "");
		return host;		
	}

	
	public static void setShop(Context mContext, String shop) {
		SharedPreferences ref = mContext.getSharedPreferences(
				DATA, 0);
		SharedPreferences.Editor editor = ref.edit();
		editor.putString(SHOP, shop);
		editor.commit();

	}		
}
